Fix idraw from PyPI wheel that fails with "invalid ELF header". - #3771
Fix idraw from PyPI wheel that fails with "invalid ELF header".#3771nrnhines wants to merge 4 commits into
Conversation
This fixes the long-standing "invalid ELF header: RTLD_GLOBAL for idraw" error that occurred with PyPI Linux wheels. - Force CMAKE_POSITION_INDEPENDENT_CODE=ON for all executables. InterViews/idraw does dlopen(self, RTLD_GLOBAL|...), which modern glibc rejects for non-PIE (ET_EXEC) binaries. - Disable IV_ENABLE_X11_DYNAMIC on Linux wheels only (SKBUILD && UNIX && NOT APPLE). The dynamic X11 loading path (ivx11_dynam.cpp) was the actual trigger of the (null) error. macOS wheels and local builds are unaffected. No functional change for normal source builds or macOS.
This reverts commit c6e37fa.
|
|
✔️ f0bdff0 -> artifacts URL |
|
✔️ f0bdff0 -> Azure artifacts URL |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3771 +/- ##
=======================================
Coverage 68.34% 68.34%
=======================================
Files 691 691
Lines 111110 111110
=======================================
Hits 75933 75933
Misses 35177 35177 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| # Force PIE for all executables (idraw, nrniv, etc.) This was the root cause of the original | ||
| # "invalid ELF header: RTLD_GLOBAL" error. | ||
| cmake_policy(SET CMP0083 NEW) |
There was a problem hiding this comment.
isn't this implied by cmake_minimum_required(VERSION 3.19 FATAL_ERROR)? I think it's only 3.13 and earlier that use the old behavior?
| ON | ||
| CACHE BOOL "Force PIE for NEURON + InterViews" FORCE) | ||
|
|
||
| # Disable fragile dynamic X11 loading *only* for Linux wheels. This was triggering the (null) |
There was a problem hiding this comment.
is there a way we could add a test for this, so we aren't bitten by it again?
There was a problem hiding this comment.
I believe so. I'll look into adding a readelf -h $NRNHOME/bin/idraw | grep Type that ought to return
$ readelf -h $NRNHOME/bin/idraw | grep Type
Type: DYN (Position-Independent Executable file)
instead of
$ readelf -h $NRNHOME/bin/idraw | grep Type
Type: EXEC (Executable file)
Ironically, I need to investigate this PR more thoroughly as, on the surface, 100% of the fix is the "Disable fragile dynamic X11 loading". (I.e. a wheel created by
$ bash packaging/python/build_wheels.bash linux 314
still shows
Type: EXEC (Executable file)
wheras one created by
$ python3.14 -m build --wheel --no-isolation --outdir /tmp/testwheel --config-setting=build.verbose=true
shows
Type: DYN (Position-Independent Executable file)



Closes #3769
This fix forces CMAKE_POSITION_INDEPENDENT_CODE=ON for all executables.
Disables IV_ENABLE_X11_DYNAMIC on Linux wheels only